layui.use(['layer','table'],function () {
    var layer=layui.layer,
        table=layui.table;
    var $ = layui.jquery;
    var uid=window.sessionStorage.getItem("uid");
    //执行一个 table 实例
    table.render({
        elem: '#coll',
        height: 580,
        url: '/Anime/userInfo/getAllColl?uid='+uid, //数据接口
        title: '视频表',
        page: true ,//开启分页
        limits:[10,20,30,40],
        cols:
            [[ //表头
                { field: 'id',title: 'ID',width: 200,sort: true,fixed: 'left'},
                { field: 'vid',title: '收藏视频',width: 300},
                { fixed: 'right', width: 100, align:'center', toolbar: '#barDemo'}
            ]]
    });
    //监听行工具事件
    table.on('tool(colltest)',function (obj) {
        var data=obj.data;
        var layEvent=obj.event;
        if(layEvent=="delete")
        {
            layer.confirm('真的取消收藏么',function (index) {
                $.ajax({
                    type:'get',
                    url:'/Anime/userInfo/delColl?id='+data.id,
                    dataType:'json',
                    success:function (res) {
                        if (res.code==0)
                        {
                            obj.del();
                            layer.msg("取消收藏成功")
                        }
                        else {
                            layer.msg("取消收藏失败");
                        }
                    }
                })
                layer.close(index);
            })
        }
    });
})